package com.hskn.hss.module.dataBigscreen.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.hskn.hss.entity.AjaxResult;
import com.hskn.hss.module.cases.entity.Cases;
import com.hskn.hss.module.dataBigscreen.service.IDataBigScreenService;
import com.hskn.hss.module.dataBigscreen.vo.AbnormalVo;
import com.hskn.hss.module.dataBigscreen.vo.CasesVo;
import com.hskn.hss.module.dataBigscreen.vo.WorkVo;
import com.hskn.hss.module.tlresplan.service.ITlEmergentResplanService;
import com.hskn.hss.utils.Tools;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author hskn
 * @since 2021-05-20
 */
@Api(tags = {"-databigscreen"}, description = "数据大屏幕")
@Slf4j
@RestController
@RequestMapping("/hss/databigscreen")
public class DataBigScreenController {

    @Autowired
    IDataBigScreenService dataBigScreenService;
    @Autowired
    ITlEmergentResplanService tlEmergentResplanService;


    /**
     * 保洁人员数据
     *
     * @param request
     * @return
     */
    @ApiOperation(value = "保洁人员数据监控", notes = "查询保洁人员数据")
    @RequestMapping(value = "personMonitor", method = RequestMethod.POST)
    public AjaxResult<Object> personMonitor(HttpServletRequest request) {
        try {
            JSONObject params = JSON.parseObject(Tools.getBody(request));
            JSONObject json = dataBigScreenService.personMonitor(params);
            return AjaxResult.success(json);
        } catch (Exception e) {
            e.printStackTrace();
            log.error("报错ERROR", e);
            return AjaxResult.fail("操作失败");
        }
    }

    /**
     * 保洁人员作业完成情况
     *
     * @param request
     * @return
     */
    @ApiOperation(value = "保洁人员作业完成情况监控", notes = "查询保洁人员作业完成情况")
    @RequestMapping(value = "personWorkMonitor", method = RequestMethod.POST)
    public AjaxResult<Object> personWorkMonitor(HttpServletRequest request) {
        try {
            JSONObject params = JSON.parseObject(Tools.getBody(request));
            JSONObject json = dataBigScreenService.personWorkMonitor(params);
            return AjaxResult.success(json);
        } catch (Exception e) {
            e.printStackTrace();
            log.error("报错ERROR", e);
            return AjaxResult.fail("操作失败");
        }
    }

    /**
     * 车辆作业数据
     *
     * @param request
     * @return
     */
    @ApiOperation(value = "车辆作业数据监控", notes = "查询车辆作业数据")
    @RequestMapping(value = "carMonitor", method = RequestMethod.POST)
    public AjaxResult<Object> carMonitor(HttpServletRequest request) {
        try {
            JSONObject params = JSON.parseObject(Tools.getBody(request));
            JSONObject json = dataBigScreenService.carMonitor(params);
            return AjaxResult.success(json);
        } catch (Exception e) {
            e.printStackTrace();
            log.error("报错ERROR", e);
            return AjaxResult.fail("操作失败");
        }
    }

    /**
     * 车辆作业完成情况
     *
     * @param request
     * @return
     */
    @ApiOperation(value = "车辆作业完成情况监控", notes = "查询车辆作业完成情况")
    @RequestMapping(value = "carWorkMonitor", method = RequestMethod.POST)
    public AjaxResult<Object> carWorkMonitor(HttpServletRequest request) {
        try {
            JSONObject params = JSON.parseObject(Tools.getBody(request));
            JSONObject json = dataBigScreenService.jxzyWorkScene(params);
            return AjaxResult.success(json);
        } catch (Exception e) {
            e.printStackTrace();
            log.error("报错ERROR", e);
            return AjaxResult.fail("操作失败");
        }
    }

    /**
     * 作业播报
     *
     * @param request
     * @return
     */
    @ApiOperation(value = "作业播报", notes = "查询作业播报数据")
    @RequestMapping(value = "workBroadcast", method = RequestMethod.POST)
    public AjaxResult<Object> workBroadcast(HttpServletRequest request) {
        try {
            JSONObject params = JSON.parseObject(Tools.getBody(request));
            List<WorkVo> json = dataBigScreenService.workBroadcast(params);
            return AjaxResult.success(json);
        } catch (Exception e) {
            e.printStackTrace();
            log.error("报错ERROR", e);
            return AjaxResult.fail("操作失败");
        }
    }

    /**
     * 设施数据
     *
     * @param request
     * @return
     */
    @ApiOperation(value = "设施数据监控", notes = "查询设施数据")
    @RequestMapping(value = "facilitiesMonitor", method = RequestMethod.POST)
    public AjaxResult<Object> facilitiesMonitor(HttpServletRequest request) {
        try {
            JSONObject params = JSON.parseObject(Tools.getBody(request));
            JSONObject json = dataBigScreenService.facilitiesMonitor(params);
            return AjaxResult.success(json);
        } catch (Exception e) {
            e.printStackTrace();
            log.error("报错ERROR", e);
            return AjaxResult.fail("操作失败");
        }
    }

    /**
     * 地图人员车辆里程
     *
     * @param request
     * @return
     */
    @ApiOperation(value = "地图人员车辆里程监控", notes = "查询地图人员车辆里程")
    @RequestMapping(value = "mileageMonitor", method = RequestMethod.POST)
    public AjaxResult<Object> mileageMonitor(HttpServletRequest request) {
        try {
            JSONObject params = JSON.parseObject(Tools.getBody(request));
            JSONObject json = dataBigScreenService.mileageMonitor(params);
            return AjaxResult.success(json);
        } catch (Exception e) {
            e.printStackTrace();
            log.error("报错ERROR", e);
            return AjaxResult.fail("操作失败");
        }
    }

    /**
     * 地图热力图
     *
     * @param request
     * @return
     */
    @ApiOperation(value = "地图热力图监控", notes = "查询地图热力图")
    @RequestMapping(value = "heatMap", method = RequestMethod.POST)
    public AjaxResult<Object> heatMap(HttpServletRequest request) {
        try {
            JSONObject params = JSON.parseObject(Tools.getBody(request));
            List<List<String>> json = dataBigScreenService.heatMap(params);
            return AjaxResult.success(json);
        } catch (Exception e) {
            e.printStackTrace();
            log.error("报错ERROR", e);
            return AjaxResult.fail("操作失败");
        }
    }

    /**
     * 异常数据
     *
     * @param request
     * @return
     */
    @ApiOperation(value = "异常数据监控", notes = "查询异常数据")
    @RequestMapping(value = "abnormalMonitor", method = RequestMethod.POST)
    public AjaxResult<Object> abnormalMonitor(HttpServletRequest request) {
        try {
            JSONObject params = JSON.parseObject(Tools.getBody(request));
            JSONObject json = dataBigScreenService.abnormalMonitor(params);
            return AjaxResult.success(json);
        } catch (Exception e) {
            e.printStackTrace();
            log.error("报错ERROR", e);
            return AjaxResult.fail("操作失败");
        }
    }

    /**
     * 异常数据播报
     *
     * @param request
     * @return
     */
    @ApiOperation(value = "异常数据播报", notes = "查询异常数据播报")
    @RequestMapping(value = "abnormalBroadcast", method = RequestMethod.POST)
    public AjaxResult<Object> abnormalBroadcast(HttpServletRequest request) {
        try {
            JSONObject params = JSON.parseObject(Tools.getBody(request));
            List<AbnormalVo> json = dataBigScreenService.abnormalBroadcast(params);
            return AjaxResult.success(json);
        } catch (Exception e) {
            e.printStackTrace();
            log.error("报错ERROR", e);
            return AjaxResult.fail("操作失败");
        }
    }

    /**
     * 应急预案
     *
     * @return
     */
    @ApiOperation(value = "应急预案数据监控", notes = "查询应急预案数据")
    @RequestMapping(value = "emergentMonitor", method = RequestMethod.POST)
    public AjaxResult<Object> emergentMonitor(HttpServletRequest request) {
        try {
            JSONObject params = JSON.parseObject(Tools.getBody(request));
            JSONObject json = dataBigScreenService.emergentMonitor(params);
            return AjaxResult.success(json);
        } catch (Exception e) {
            e.printStackTrace();
            log.error("报错ERROR", e);
            return AjaxResult.fail("操作失败");
        }
    }

    /**
     * 应急预案计划下发时间走势
     *
     * @param request
     * @return
     */
    @ApiOperation(value = "应急预案计划下发时间走势", notes = "查询应急预案计划下发时间走势")
    @RequestMapping(value = "emergentPlanTimeTrend", method = RequestMethod.POST)
    public AjaxResult<Object> emergentPlanTimeTrend(HttpServletRequest request) {
        try {
            JSONObject params = JSON.parseObject(Tools.getBody(request));
            List<Map> json = dataBigScreenService.emergentPlanTimeTrend(params);
            return AjaxResult.success(json);
        } catch (Exception e) {
            e.printStackTrace();
            log.error("报错ERROR", e);
            return AjaxResult.fail("操作失败");
        }
    }

    /**
     * 应急播报
     *
     * @param request
     * @return
     */
    @ApiOperation(value = "应急播报", notes = "查询应急播报")
    @RequestMapping(value = "emergentBroadcast", method = RequestMethod.POST)
    public AjaxResult<Object> emergentBroadcast(HttpServletRequest request) {
        try {
            JSONObject params = JSON.parseObject(Tools.getBody(request));
            List<Map> json = dataBigScreenService.emergentBroadcast(params);
            return AjaxResult.success(json);
        } catch (Exception e) {
            e.printStackTrace();
            log.error("报错ERROR", e);
            return AjaxResult.fail("操作失败");
        }
    }

    /**
     * 巡查案件
     *
     * @param request
     * @return
     */
    @ApiOperation(value = "巡查案件数据监控", notes = "查询巡查案件")
    @RequestMapping(value = "patrolCasesMonitor", method = RequestMethod.POST)
    public AjaxResult<Object> patrolCasesMonitor(HttpServletRequest request) {
        try {
            JSONObject params = JSON.parseObject(Tools.getBody(request));
            CasesVo casesVo = dataBigScreenService.patrolCasesMonitor(params);
            return AjaxResult.success(casesVo);
        } catch (Exception e) {
            e.printStackTrace();
            log.error("报错ERROR", e);
            return AjaxResult.fail("操作失败");
        }
    }

    /**
     * 案件播报
     *
     * @param request
     * @return
     */
    @ApiOperation(value = "案件播报", notes = "查询案件播报")
    @RequestMapping(value = "caseBroadcast", method = RequestMethod.POST)
    public AjaxResult<Object> caseBroadcast(HttpServletRequest request) {
        try {
            JSONObject params = JSON.parseObject(Tools.getBody(request));
            List<Cases> json = dataBigScreenService.caseBroadcast(params);
            return AjaxResult.success(json);
        } catch (Exception e) {
            e.printStackTrace();
            log.error("报错ERROR", e);
            return AjaxResult.fail("操作失败");
        }
    }
}

